#ifndef AVIATION_USER_H
#define AVIATION_USER_H

#include "util.h"

#include <string>

#include <boost/serialization/nvp.hpp>

namespace aviation
{

/// This class represents a user of the system, including a username and hashed password.
class User
{
public:

	typedef std::string String;

	/// Default constructor; creates a reasonable default user.
	User();
	/// Copy constructor; constructs one User from another.
	User(const User& other);
	/// Constructs a user from a username, password and a bool that says whether the user has admin rights.
	User(const String userName, const String passWord, const bool adminRights);
	/// Trivial destructor.
	~User();

	/// Assigns the value of one User to another.
	User& operator=(const User& other);

	/// Returns true if they are the same, or false if they are not.
	const bool operator==(const User& other) const;
	/// Strict weak ordering comparison operator.
	/// \returns True if the left User is strictly less than the other.
	const bool operator<(const User& other) const;

	/// Returns the username as a string.
	const String GetUsername() const;
	/// Returns the admin status: true if the user is an admin, or false if they are not.
	const bool IsAdmin() const;
	/// Returns the hashed password as an integer.
	const unsigned GetHashedPassword() const;

	/// Serialization (file I-O) function.
	/// \param ar A boost::archive formatter type.
	/// \param version The file version.
	template <class Archive>
	void serialize(Archive& ar, unsigned int version);

private:

	String m_userName;
	unsigned m_hashedPassword;
	bool m_adminRights;
};

template <class Archive>
void User::serialize(Archive& ar, unsigned int version)
{
	ar & BOOST_SERIALIZATION_NVP(m_userName);
	ar & BOOST_SERIALIZATION_NVP(m_hashedPassword);
	ar & BOOST_SERIALIZATION_NVP(m_adminRights);
}

} // namespace aviation

#endif // AVIATION_USER_H